app.register.controller('detail',['$scope', '$rootScope', '$routeParams',function($scope, $rootScope, $routeParams, content) {
    //$scope.id = $routeParams.id;
    //$scope.listId = $routeParams.listId;
    //$scope.inputText = "";
    //$scope.list = content.getList($scope.listId,$scope.id);
    //log($scope.list);
    //log($rootScope.list);
    //$scope.add = function(){
    //    var id = $scope.list.length -1;
    //    $scope.list.push({id:id,text:$scope.inputText});
    //    $scope.inputText = "";
    //};
    //$scope.del = function(id){
    //    $scope.list.splice(id, 1);
    //};
    $scope.currentPage = Number($routeParams.pageId);
    $scope.count =300;
    $scope.onePageNum = 6;
    $scope.pageNum = 5;

    function init(){
        $scope.list = [];
        $scope.pageList = [];
        var listNum = 0;
        if($scope.currentPage*$scope.onePageNum<$scope.count){
            listNum=$scope.onePageNum;
        }else{
            listNum=6-($scope.currentPage*$scope.onePageNum-$scope.count);
        }
        for(var i=0;i<listNum;i++){
            $scope.list.push(i);
        }
        $scope.countPage = Math.ceil($scope.count / $scope.onePageNum);
        if($scope.currentPage < 1 || $scope.currentPage > $scope.countPage) $scope.currentPage = 1;
        for(var i = 1;i<=$scope.countPage;i++){
            if($scope.currentPage - i < $scope.pageNum && $scope.currentPage - i >= 0){
                $scope.pageList.push(i);
            }else if(i - $scope.currentPage < $scope.pageNum && i - $scope.currentPage >= 0){
                if($scope.pageList.length < $scope.pageNum){
                    $scope.pageList.push(i);
                }else{
                    if(i <= $scope.currentPage + (($scope.pageNum - 1)/2)){
                        $scope.pageList.shift();
                        $scope.pageList.push(i);
                    }
                }
            }
        }
    }
    init();

    $scope.del = function(){
        $scope.count --;
        init();
    }
}]);